package com.ant.androidBuddy;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

public class Widget extends AppWidgetProvider {
	@Override
	public void onUpdate(Context context, AppWidgetManager appWidgetManager,
			int[] appWidgetIds) {
		RemoteViews remoteViews;

		for (int i = 0; i < appWidgetIds.length; i++) {
			Intent updateServiceIntent = new Intent(context,
					OpenFileActivity.class);
			PendingIntent updateServicePendingIntent = PendingIntent
					.getActivity(context, 0, updateServiceIntent,
							PendingIntent.FLAG_UPDATE_CURRENT);

			remoteViews = new RemoteViews(context.getPackageName(),
					R.layout.activity_widget);
			remoteViews
					.setImageViewResource(R.id.imageView, R.drawable.android);

			remoteViews.setOnClickPendingIntent(R.id.openBtn,
					updateServicePendingIntent);
			appWidgetManager.updateAppWidget(appWidgetIds[i], remoteViews);
		}
		super.onUpdate(context, appWidgetManager, appWidgetIds);
	}

	@Override
	public void onReceive(Context context, Intent intent) {
		super.onReceive(context, intent);
	}
}
